
/**
 * Record pre-insert trigger.
 * Validate the record to be inserted.
 * When false is returned the record will not be inserted in the database.
 * When an exception is thrown the record will also not be inserted in the database but it will be added to databaseManager.getFailedRecords(),
 * the thrown exception can be retrieved via record.exception.getValue().
 *
 * @param {JSRecord<db:/cepario/pacientes>} record record that will be inserted
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"138738BB-1347-461B-B7E7-9C936372338A"}
 */
function onRecordInsert_pacientes(record) 
{
	// return boolean to indicate success
	
	record.nombre_completo = record.apellido + ', ' + record.nombre
	return true
}

/**
 * Record pre-update trigger.
 * Validate the record to be updated.
 * When false is returned the record will not be updated in the database.
 * When an exception is thrown the record will also not be updated in the database but it will be added to databaseManager.getFailedRecords(),
 * the thrown exception can be retrieved via record.exception.getValue().
 *
 * @param {JSRecord<db:/cepario/pacientes>} record record that will be updated
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"8269C0D4-6E5C-4D53-9B52-F93A29925FC4"}
 */
function onRecordUpdate(record) {
	record.nombre_completo = record.apellido + ', ' + record.nombre
	return true
}

/**
 * Record pre-delete trigger.
 * Validate the record to be deleted.
 * When false is returned the record will not be deleted in the database.
 * When an exception is thrown the record will also not be deleted in the database but it will be added to databaseManager.getFailedRecords(),
 * the thrown exception can be retrieved via record.exception.getValue().
 *
 * @param {JSRecord<db:/cepario/pacientes>} record record that will be deleted
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"3215715E-24CA-4742-BCD8-3434D4D85908"}
 */
function onRecordDelete_pacientes(record) 
{
	record.pacientes_to_paciente_clinica.deleteAllRecords()
	record.pacientes_to_paciente_diagnostico.deleteAllRecords()
	return true
/*	// NO SE PERMITEN BAJAS
	return false*/
}
